package org.swan.web.role.mapper;

import org.apache.ibatis.annotations.*;
import org.swan.web.role.bean.RolePermissionBean;
import java.util.List;
import java.util.Optional;

public interface RolePermissionMapper {
    @Insert("insert into role_permission ( role_id , permission_id ) VALUES ( #{roleId} , #{permissionId})")
    @Options(useGeneratedKeys = true, keyProperty = "rolePermissionId")
    long add(RolePermissionBean ub);

    @Select("select * from role_permission where role_permission_id = #{id}")
    Optional<RolePermissionBean> getById(@Param("id") long id);

    @Update("update role_permission set  where role_permission_id = #{rolePermissionId}  ")
    long updateById(RolePermissionBean RolePermissionBean);

    @Delete("delete from role_permission where role_permission_id = #{RolePermissionId}")
    long deleteById(@Param("RolePermissionId") long RolePermissionId);

    @Select("select * from role_permission limit #{rows} offset #{offset}")
    List<RolePermissionBean> list(@Param("offset") int offset, @Param("rows") int rows);
}
